<template>
  <div class="pop-up-child" v-if="showLookingBack">
    <header class="header">
      <p class="title" v-text="sheetTitle"></p>
      <div class="close" @click="close">
        <Iconfont iconClass="cha1"/>
      </div>
    </header>
    <div class="list-content">
      <ul class="pop-child-content" v-infinite-scroll="loadMore" infinite-scroll-disabled="busy" infinite-scroll-distance="10">
        <li class="pop-list" v-for="(v) in liveBackData" :key='v.id' @click="clickLookBack(v)">
          <div class="con-img">
            <img :src="v.imagUrl+'?x-oss-process=image/resize,m_fixed,h_190,w_350'" v-on:click.self.prevent>
          </div>
          <p class="look-title">{{v.title}}</p>
        </li>
      </ul>
      <p class="tip-text">{{tipText}}</p>
    </div>
  </div>
</template>
<script>
export default {
  components: {
  },
  props:{
    roomInfo:String,//房间信息
    sheetTitle: String//标题
	},
  data() {
    return {
      showLookingBack: true,
      ownerid: '', // 主播id
      liveBackData: [], //回看数组
      page: 0,
      busy: false, //打开滚动
      tipText: "",//底部文本提示
    }
  },
  methods: {
    close() {
      this.$emit("formChildMsg",{
        type: "footerActionSheetClose",
        data: ''
      })
    },
    loadMore: function() {
      this.busy = true//放在数据请求{this.getAnchorArray()}的外面，避免不断重复加载的现象

      this.tipText = "数据加载中..."
        // 多次加载数据
      setTimeout(() => {//延迟，为了 防抖
        this.page++;
        this.getLiveBackArr();
      }, 10);
    },
    getLiveBackArr() {
      this.$http.get('/h5live/getRoomVideoList', {
        params: {
          p: this.page,//第几页
          anchor: this.roomInfo.roomInfo.anchor,//主播id
          type: null,//类型   空 所有数据
        }
      } )
      .then(res => {
        if(res.data.code == '000000'){
          if (res.data.data.length) {
            this.liveBackData = [...this.liveBackData,...res.data.data];
            this.busy = false;//数据请求成功，打开 上拉加载
            if (res.data.data.length < 10) {
              this.busy = true;//禁用
              this.tipText = "没有更多数据了"
            }
          } else {
            this.busy = true; //禁用
            this.page = 0
            this.tipText = "没有更多数据了"
          }

        }
      })
      .catch(response => {
        console.log(response);
      });
    },
    //跳转回看详情页面
    clickLookBack(v) {
      this.$store.dispatch("showMask", false);//关闭遮罩层
    	if(this.pageType=='smallVideo'){
    		this.$router.push({
		             path: `/${this.$channel}/smallVideoPlaypage`,
		             query: {
			            videoinfo: v
			          }
		         });
    	}else{
    		this.$router.push({
             path: `/${this.$channel}/liveBack/${v.id}?dzhPage=true`
         });
    	}

    }
  },
};
</script>
<style scoped lang="less">
.pop-up-child {
  width: 100%;
  min-height: 220px;
  background: #fff;
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 1006;
  border-radius: 20px 20px 0px 0px;
}

.pop-up-child .header {
  line-height: 64px;
  text-align: center;
  position: relative;
}

.pop-up-child .title {
  font-size: 28px;
  font-weight: bold;
  color: #666666;
}

.pop-up-child .close {
  position: absolute;
  top: 0;
  right: 0;
}

.pop-up-child .iconcha1 {
  padding: 0 30px;
  font-size: 18px;
  color: #c8c9cc;
}

.list-content {
  width: 100vw;
  max-height: calc(56vh - 64px);
  overflow-y: scroll;
}

.pop-child-content {
  padding-bottom: 20px;
  margin-left: 30px;
  margin-right: 30px;
  display: flex;
  flex-wrap: wrap;
}

.pop-list {
  width: 325px;
  height: 284px;
  margin-top: 20px;
  margin-left: 30px;
}

.pop-list:nth-child(odd) {
  margin-left: 0px;
}

.con-img img {
  display: block;
  width: 325px;
  height: 190px;
  border-radius: 20px;
}

.look-title {
  width: 100%;
  height: 84px;
  font-size: 24px;
  font-weight: 400;
  color: #434249;
  line-height: 42px;
  white-space: pre-wrap;
  text-align: justify;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-top: 10px;
}

.tip-text {
  width: 100%;
  height: 80px;
  line-height: 80px;
  color: #999999;
  text-align: center;
  font-size: 26px;
  margin-top: 30px;
}
</style>
